package com.zhanghe.security.util.auth2.github;

import com.zhanghe.security.util.HttpClientUtil;
import com.zhanghe.security.util.auth2.Oauth2Token;

public class GithubAuthUtil {
    /**
     * 获取用户token
     * @param code
     * @return
     */
    public static Oauth2Token getOauth2Token(String code){
        return HttpClientUtil.get("https://github.com/login/oauth/access_token?client_id=9304cb97ee37d73f175c&client_secret=3beebc040dfa8234e59883d67106f60cca83a090&code="+code , Oauth2Token.class);
    }

    public static GithubUserInfo getGithubUserInfo(String access_token){
        return HttpClientUtil.get("https://api.github.com/user?access_token="+access_token , GithubUserInfo.class);
    }
}
